Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sst5 support instead of sst2 #1

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

sst5 support instead of sst2 #1

wants to merge 2 commits into from

Conversation

nikolawhallon
Copy link
Collaborator

@nikolawhallon nikolawhallon commented Nov 4, 2022

For sentiment, sst5 predicts 5 sentiment categories - "very positive", "positive", "neutral", "negative", and "very negative".

sst2 predicts 2 sentiment categories - "positive" and "negative".

rust-bert only supports sst2, not sst5, but we want to use sst5

This is a somewhat ugly, though not that bad imo hot-fix - the proper solution might be to work on getting rust-bert to support both, or rather to support reading a config file with a label -> sentiment mapping (although that would remove the ability to have the sentiment values be in an enum) - I don't see how to do that without making a breaking API change?

This also is added on top of a particular commit - I was not able to easily update our rust-bert to 0.19.

@mlodato517
Copy link

Sorry - could you give more details here? 😅 What's "sst2"? What's "sst5"?

@nikolawhallon
Copy link
Collaborator Author

Sorry - could you give more details here? sweat_smile What's "sst2"? What's "sst5"?

I added some such info in the description.

Copy link

@mlodato517 mlodato517 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems reasonable to me so far! Other implementations can be figured out if/when we contribute this upstream or if/when we change our production model.

@@ -141,8 +142,10 @@ impl SentimentModel {
let labels = self.sequence_classification_model.predict(input);
let mut sentiments = Vec::with_capacity(labels.len());
for label in labels {
let polarity = if label.id == 1 {
let polarity = if label.id == 4 || label.id == 3 {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay so this basically gains us sst5 but loses us sst2 but that's fine because the current production model we're using is sst5. And this is why, as you mention in the PR description, it'd be great to get this into rust-bert as something configurable per model so the sentiment pipeline works with whatever IDs the underlying model will return?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes - and I think it would be a fun rust-bert contribution to try, but maybe tricky.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I wonder how these models work and if we could get "lucky" with a "specify the neutral range and anything above that is positive and anything below is negative". But it's technically more flexible to require the mapping as you say. Yeah interesting to try and figure out.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, the models often come with something like config.json which explicitly contains the mapping.

@nikolawhallon
Copy link
Collaborator Author

Seems reasonable to me so far! Other implementations can be figured out if/when we contribute this upstream or if/when we change our production model.

Thanks for double checking this - one question will remain, should this actually get merged? The PR is useful to get a review, but I imagine it's easier to keep this in a branch which we point to. Is there a canonical preference?

@mlodato517
Copy link

should this actually get merged? The PR is useful to get a review, but I imagine it's easier to keep this in a branch which we point to. Is there a canonical preference?

Yeah that is a good question. I feel like normally the process is:

  1. fork repo
  2. make branch with fixes you need
  3. make PR from your fork to upstream repo
  4. reference your branch in your fork while you
  5. update to use upstream when PR is merged

but here we're like 100% sure that the thing we PR to rust-bert will not be the same as this branch 🤔

Might be best to dismiss my approval and add commits to this branch to approach the thing we think we'd submit to rust-bert. Then, one day, we can squash all the commits and make a PR to them without disrupting our use of it?

I think we could also merge this and other PRs into our master and then one day make a PR from our master to their master that, in sum, has "the right change".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants